﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YJKRevitArea.AreaSet
{
	public partial class FireZoneSetForm : System.Windows.Forms.Form
	{
		public FireZoneSetForm(FireZoneLableInfo labelInfo, bool refreshExist)
		{
			this.InitializeComponent();
			this.m_labelInfo = labelInfo;
			this.chkFireZoneName.Checked = labelInfo.m_name;
			this.chkFireZoneNum.Checked = labelInfo.m_number;
			this.chkFireZoneArea.Checked = labelInfo.m_area;
			if ("平方米" == labelInfo.m_language)
			{
				this.radChinese.Checked = true;
			}
			else
			{
				this.radEnglish.Checked = true;
			}
			this.chkRemark.Checked = labelInfo.m_remark;
			for (int i = 1; i < 17; i++)
			{
				this.cbLineWidth.Items.Add(i.ToString());
			}
			int selectedIndex = this.cbLineWidth.Items.IndexOf(labelInfo.m_lineWidth.ToString());
			this.cbLineWidth.SelectedIndex = selectedIndex;
			this.m_color = Common.IntToRgbColor(labelInfo.m_lineColor);
			this.btnColor.BackColor = this.m_color;
			this.m_refreshExist = refreshExist;
			this.cbRefresh.Checked = this.m_refreshExist;
		}

		private void FireZoneSetForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.m_labelInfo.m_name = this.chkFireZoneName.Checked;
			this.m_labelInfo.m_number = this.chkFireZoneNum.Checked;
			this.m_labelInfo.m_area = this.chkFireZoneArea.Checked;
			this.m_labelInfo.m_remark = this.chkRemark.Checked;
			this.m_labelInfo.m_lineWidth = int.Parse(this.cbLineWidth.Text);
			this.m_labelInfo.m_lineColor = Common.RgbColorToInt(this.m_color);
			if (this.radChinese.Checked)
			{
				this.m_labelInfo.m_language = "平方米";
			}
			else
			{
				this.m_labelInfo.m_language = "m2";
			}
			this.m_refreshExist = this.cbRefresh.Checked;
		}

		private void btnColor_Click(object sender, EventArgs e)
		{
			ColorDialog colorDialog = new ColorDialog();
			if (DialogResult.OK == colorDialog.ShowDialog())
			{
				this.m_color = colorDialog.Color;
				this.btnColor.BackColor = this.m_color;
			}
		}

		protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{
			int num = 256;
			int num2 = 260;
			if ((msg.Msg == num | msg.Msg == num2) && keyData == Keys.Escape)
			{
				base.Close();
			}
			return false;
		}

		public FireZoneLableInfo m_labelInfo;

		public bool m_refreshExist;

		private System.Drawing.Color m_color = System.Drawing.Color.Red;
	}
}
